package me.zhengjie.controller;
import me.zhengjie.pojo.dto.LiftRequestDto;
import me.zhengjie.service.LiftTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/lift")
public class LiftController {


    @Autowired
    private final LiftTaskService liftTaskService;

    public LiftController(LiftTaskService liftTaskService) {
        this.liftTaskService = liftTaskService;
    }

    //获取token
    @PostMapping("/developerLogin")
    public  String  developerLogin(String robotId) throws Exception {
        return liftTaskService.developerLogin(robotId);
    }

    //预约单云电梯
    @PostMapping("/callElevator")
    private  String callElevator(LiftRequestDto liftRequestDto) throws Exception {
        return liftTaskService.callElevator(liftRequestDto);
    }


    //设置回调地址
    @PostMapping("/setCallBack")
    private  String setCallBack(LiftRequestDto liftRequestDto) throws Exception {
        return liftTaskService.setCallBack(liftRequestDto);
    }

    //发送开门指令
    @PostMapping("/sendOpenDoor")
    private  String sendOpenDoor(LiftRequestDto liftRequestDto) throws Exception {
        return liftTaskService.sendOpenDoor(liftRequestDto);
    }

    //回调数据
    @PostMapping("callback/url")
    public void callbackUrl(String encrypt) throws Exception {
        liftTaskService.callbackUrl(encrypt);
    }

}
